//-----------------------------------------------------------------------
// <copyright file="Message.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Microsoft.Live.Messenger
{
    using System;
    using System.Diagnostics;

    /// <summary>
    /// Represents a message that is sent between instant messaging addresses.
    /// </summary>
    public abstract class Message
    {
        private IMAddress sender;

        /// <summary>
        /// Initializes a new instance of the <see cref="Message"/> class.
        /// </summary>
        /// <param name="messageType">The message type.</param>
        internal Message()
        {
        }

        internal abstract MessengerEntity Entity
        {
            get;
        }

        /// <summary>
        /// Gets the sending instant messaging address.
        /// </summary>
        public IMAddress Sender
        {
            get { return this.sender; }
            internal set { this.sender = value; }
        }

        /// <summary>
        /// Gets the message type.
        /// </summary>
        public MessageType Type
        {
            get { return this.Entity.GetEnumProperty<MessageType>("Type"); }
        }

        /// <summary>
        /// Gets the timestamp the message was sent or received.
        /// </summary>
        public DateTime Timestamp
        {
            get { return this.Entity.GetProperty<DateTime>("Timestamp"); }
        }
    }
}